﻿using Basic.FlowGatewayModule.Interface;
using Basic.FlowRemoteModel.Flow.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FlowGatewayModule.Api
{
    [ApiRouteName("/flow/info/{name}")]
    internal class FlowApi : ApiController
    {
        private readonly IFlowService _Service;

        public FlowApi ( IFlowService service )
        {
            this._Service = service;
        }
        [ApiPower("all", "flow.info.copy")]
        public long Copy ( FlowCopy param )
        {
            return this._Service.Copy(param, base.UserState.ToEmpId());
        }
        public long[] GetFormId ( [NumValidate("flow.id.error", 1)] long id )
        {
            return this._Service.GetFormId(id);
        }
        public FlowFormDto[] GetForms ( [NumValidate("flow.id.error", 1)] long id )
        {
            return this._Service.GetForms(id);
        }
        public string GetName ( [NumValidate("flow.id.error", 1)] long id )
        {
            return this._Service.GetName(id);
        }
        public FlowChildren GetChildren ( [NumValidate("flow.id.error", 1)] long id )
        {
            return this._Service.GetChildren(id);
        }
        [ApiPower("all", "flow.info.add")]
        public long Add ( FlowAdd data )
        {
            data.CreateBy = base.UserState.ToEmpId();
            return this._Service.Add(data);
        }
        [ApiPower("all", "flow.info.delete")]
        public void Delete ( [NumValidate("flow.id.error", 1)] long id )
        {
            this._Service.Delete(id);
        }
        [ApiPower("all", "flow.info.set")]
        public EnableFlowResult Enable ( [NumValidate("flow.id.error", 1)] long id )
        {
            return this._Service.Enable(id);
        }
        [ApiPower("all", "flow.info.set")]
        public bool Stop ( [NumValidate("flow.id.error", 1)] long id )
        {
            return this._Service.Stop(id);
        }
        public EnableFlowResult Check ( [NumValidate("flow.id.error", 1)] long id )
        {
            return this._Service.Check(id);
        }
        public FlowDto Get ( [NumValidate("flow.id.error", 1)] long id )
        {
            return this._Service.Get(id);
        }

        public PagingResult<FlowData> Query ( PagingParam<FlowQueryParam> param )
        {
            return this._Service.Query(param);
        }
        [ApiPower("all", "flow.info.set")]
        public bool Set ( LongParam<FlowSet> data )
        {
            return this._Service.Set(data.Id, data.Value);
        }
    }
}
